using System;
using System.Collections.Generic;
using System.Text;
using MyClever.Lib;

namespace MyCleverConsole
{
    class Program
    {        
        static int Main(string[] args)
        {
            List<string> files = new List<string>();
            if (args.Length > 0)
            {
                files.AddRange(args[0].Split(';'));
            }

            int numErrors = 0;
            foreach (string fileOn in files)
            {
                Console.WriteLine("start mission: " + fileOn);
                
                Mission mission = new Mission(fileOn);
                mission.Start();

                foreach (MissionPluginProxy pluginOn in mission.GetDefectivePlugins())
                {
                    Console.Error.WriteLine("\n\n--------ATTENTION---------");
                    Console.Error.WriteLine(String.Format("error in mission-file: '{0}'", fileOn));
                    Console.Error.WriteLine(String.Format("plugin '{0}' (id:{1}) (version: {2}) execute following errors:", pluginOn.ClassName, pluginOn.ID, pluginOn.GetProperty(PluginProperty.Version)));

                    foreach (string errorMessage in pluginOn.GetErrorMessages())
                    {
                        Console.Error.WriteLine(errorMessage);
                        numErrors++;
                    }                                     
                }
                mission = null;

                Console.Read();
            }
            return numErrors;
        }
    }
}
